module rank {


    export class GameSpriteSheet {

        private info: any = {"file":"rank.png","frames":{
                "poster":{"x":0,"y":0,"w":750,"h":1334,"offX":0,"offY":0,"sourceW":750,"sourceH":1334},
                "tab_unselected":{"x":1790,"y":233,"w":132,"h":60,"offX":0,"offY":0,"sourceW":132,"sourceH":60},
                "tab_selected":{"x":1889,"y":0,"w":132,"h":60,"offX":0,"offY":0,"sourceW":132,"sourceH":60},
                "rank_medal_3":{"x":1928,"y":62,"w":37,"h":50,"offX":0,"offY":0,"sourceW":37,"sourceH":50},
                "rank_medal_2":{"x":1889,"y":62,"w":37,"h":50,"offX":0,"offY":0,"sourceW":37,"sourceH":50},
                "rank_medal_1":{"x":1924,"y":233,"w":37,"h":50,"offX":0,"offY":0,"sourceW":37,"sourceH":50},
                "rank_item":{"x":1354,"y":141,"w":600,"h":90,"offX":0,"offY":0,"sourceW":600,"sourceH":90},
                "rank_bg":{"x":752,"y":0,"w":600,"h":796,"offX":0,"offY":0,"sourceW":600,"sourceH":796},
                "btn_prev_page":{"x":1354,"y":314,"w":296,"h":90,"offX":0,"offY":0,"sourceW":296,"sourceH":90},
                "btn_next_page":{"x":1652,"y":314,"w":296,"h":90,"offX":0,"offY":0,"sourceW":296,"sourceH":90},
                "btn_fight":{"x":1354,"y":233,"w":434,"h":79,"offX":0,"offY":0,"sourceW":434,"sourceH":79},
                "limit_time_rank_header":{"x":1354,"y":0,"w":533,"h":139,"offX":0,"offY":0,"sourceW":533,"sourceH":139}}};

        private spriteSheet: egret.SpriteSheet;

        public constructor(img: egret.Texture) {
            this.spriteSheet = new egret.SpriteSheet(img);
        }

        public getTexture(key: string): egret.Texture {
            let frames: any = this.info["frames"];
            let frame = frames[key];
            if (!frame.isCreated) {
                let texture = this.spriteSheet.createTexture(key, frame.x, frame.y, frame.w, frame.h);
                frame.isCreated = true;
                return texture;
            }
            return this.spriteSheet.getTexture(key);
        }

        public getBitmap(key: string): egret.Bitmap {
            return new egret.Bitmap(this.getTexture(key));
        }

    }

}